/**
 * 
 */
package de.hft_stuttgart.dsa.ctt.app;

import de.hft_stuttgart.dsa.ctt.model.CourseAssignmentMatrix;
import de.hft_stuttgart.dsa.ctt.model.CourseAvailabilityMatrix;
import de.hft_stuttgart.dsa.ctt.model.ProblemInstance;
import de.hft_stuttgart.dsa.ctt.processing.IAssigner;
import de.hft_stuttgart.dsa.ctt.processing.Preprocessor;
import de.hft_stuttgart.dsa.ctt.processing.yuruz.YuruzAssigner;
import de.hft_stuttgart.dsa.ctt.reader.DatasetReader;
import de.hft_stuttgart.dsa.ctt.reader.OutputReader;
import de.hft_stuttgart.dsa.ctt.validation.FeasibleSolutionChecker;
import de.hft_stuttgart.dsa.ctt.validation.FitnessEvaluator;

/**
 * @author Ali Yuruz
 */
public class Start {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// testAssigner();
		//testOutputReader();
		testFitnessEvaluator();
	}

	private static void testFitnessEvaluator() {
		String dataSet = DatasetReader.DATASET12;
		String solutionFilePath = "FeasibleSolutions(Website checked)/Fis0506-1_20100609_170128247.ctt";
		solutionFilePath = "FeasibleSolutions(Website checked)/Let0506-2_20100609_172422469.ctt";
		new FitnessEvaluator(getProbleminstance(dataSet), readOutput(solutionFilePath, dataSet)).calculateSoftConstraintPenalty();

	}

	private static CourseAssignmentMatrix readOutput(String solutionFilePath, String dataSet) {
		OutputReader outputReader = new OutputReader();
		return outputReader.generateMatrixFromOutput(solutionFilePath, dataSet);

	}

	private static ProblemInstance getProbleminstance(String dataSet) {
		return new DatasetReader().readDataset(dataSet);
	}

	private static void testOutputReader() {
		String outputFilePath = "FeasibleSolutions(Website checked)/Fis0506-1_20100609_170128247.ctt";

		OutputReader outputReader = new OutputReader();
		System.out.println(outputReader.generateMatrixFromOutput(outputFilePath, DatasetReader.DATASET1));

	}

	private static void testAssigner() {
		ProblemInstance problemInstance = new DatasetReader().readDataset(DatasetReader.DATASET1);
		CourseAvailabilityMatrix matrix = new CourseAvailabilityMatrix(problemInstance.getRooms(), problemInstance.getPeriods());
		Preprocessor preprocessor = new Preprocessor(problemInstance, matrix);
		preprocessor.processCourseAvailabilityMatrix();
		System.out.println(problemInstance.getCurricula());

		IAssigner assigner = new YuruzAssigner(problemInstance, matrix);

		CourseAssignmentMatrix cAssignmentMatrix = assigner.assignCoursesToMatrix();
		System.out.println(cAssignmentMatrix);

		System.out.println("Oldu mu?" + new FeasibleSolutionChecker(cAssignmentMatrix, problemInstance).checkSolution());

	}

}
